%2 is an easy way of testing if a number is odd or even.
def modulo3(num):
result = num % 2 == 1
return result
Function Call | Return Value | |||
---|---|---|---|---|
modulo3(9) | → | |||
modulo3(13) | → | |||
modulo3(10) | → | |||
modulo3(31) | → | |||
modulo3(8) | → |
Experiment with this code on Gitpod.io